package nc.bs.pub.action;

import nc.bs.common.projectFAUtils;
import nc.bs.framework.common.NCLocator;
import nc.bs.pub.compiler.AbstractCompiler2;
import nc.itf.pu.m21.IOrderApprove;
import nc.vo.pu.m21.context.OrderContext;
import nc.vo.pu.m21.entity.OrderVO;
import nc.vo.pu.m21.pub.OrderContextUtil;
import nc.vo.pub.BusinessException;
import nc.vo.pub.compiler.PfParameterVO;
import nc.vo.pubapp.pub.power.PowerActionEnum;
import nc.vo.scmpub.res.billtype.POBillType;
import nc.vo.uap.pf.PFBusinessException;
import nccloud.vo.scmpub.utils.power.DataPermissionUtil;

public class N_21_APPROVE extends AbstractCompiler2 {
	public String getCodeRemark() {
		return "\tnc.vo.pu.m21.entity.OrderVO[] inObject  =(nc.vo.pu.m21.entity.OrderVO[])getVos ();\nObject retValue=nc.bs.framework.common.NCLocator.getInstance().lookup(nc.itf.pu.m21.IOrderApprove.class).approve(inObject, this);\nreturn retValue;\n";
	}

	public Object runComClass(PfParameterVO vo) throws BusinessException {
		try {
			super.m_tmpVo = vo;
			OrderVO[] inObject = (OrderVO[]) ((OrderVO[]) this.getVos());
			if (vo.isCloudEntry) {
				DataPermissionUtil.checkPermission(inObject, POBillType.Order.getCode(),
						PowerActionEnum.APPROVE.getActioncode(), "vbillcode");
			}

			OrderContext[] ctxs = OrderContextUtil.getCtxs(vo);
			
			//lhw 231128 保存前校验项目 begin
			new projectFAUtils().projectDataApprove("po_order", inObject, "approve");
			//end
			
			Object retValue = ((IOrderApprove) NCLocator.getInstance().lookup(IOrderApprove.class)).approve(inObject,
					this, ctxs);
			return retValue;
		} catch (Exception var5) {
			if (var5 instanceof BusinessException) {
				throw (BusinessException) var5;
			} else {
				throw new PFBusinessException(var5.getMessage(), var5);
			}
		}
	}
}